{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "whtat is wrong?\n",
      "what's wrong?\n",
      "\\\n",
      "C:\\Users\\Administrator\\Desktop\n"
     ]
    }
   ],
   "source": [
    "print('whtat is wrong?')\n",
    "print('what\\'s wrong?') # 需要转义字符\n",
    "\n",
    "print('\\\\') # 转义字符\n",
    "print(r'C:\\Users\\Administrator\\Desktop') # 去掉转义字符的功能"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "btc_usdt\n",
      "******************************\n"
     ]
    }
   ],
   "source": [
    "# 相加\n",
    "symbol1 = 'btc'\n",
    "symbol2 = 'usdt'\n",
    "symbol = symbol1 + '_' + symbol2\n",
    "print(symbol)\n",
    "print('*' * 30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "# 判断\n",
    "print(symbol.startswith('btc'))  # 是否以某str开头\n",
    "print('usdt' in symbol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "btc_usdt\n",
      "ltc_usdt\n"
     ]
    }
   ],
   "source": [
    "# replace\n",
    "symbol.replace('btc','ltc')\n",
    "print(symbol)\n",
    "print(symbol.replace('btc','ltc'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['btc', 'usdt', 'ltc']\n",
      "btc\n",
      "btc and usdt and ltc\n"
     ]
    }
   ],
   "source": [
    "# 分割 && join\n",
    "res = 'btc,usdt,ltc'.split(',')\n",
    "print(res)\n",
    "print(res[0])\n",
    "\n",
    "final = ' and '.join(res)\n",
    "print(final)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bijingrui\n",
      "bijingrui\n"
     ]
    }
   ],
   "source": [
    "# 去除str边上的某些str\n",
    "symbol = '   bijingrui   '\n",
    "symbol = symbol.strip()\n",
    "print(symbol)\n",
    "\n",
    "symbol = '|||||||||bijingrui||'\n",
    "symbol = symbol.strip('|')\n",
    "print(symbol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "l\n",
      "ltc\n",
      "_usdt\n"
     ]
    }
   ],
   "source": [
    "# 字符串选取，把str当做list\n",
    "symbol = 'ltc_usdt'\n",
    "print(symbol[0])\n",
    "print(symbol[:3])\n",
    "print(symbol[3:])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
